﻿

Namespace Aricie.DNN.Services.Url.FriendlyUrl.Providers
    Public Class DnnWikiUrlRewriter
        Implements IUrlRewriterProvider
        Implements IIsActive


        Public Function GetModuleRewrites() As List(Of GroupParamsRewrite) Implements IUrlRewriterProvider.GetRewrites
            Dim toReturn As New List(Of GroupParamsRewrite)
            Dim desc As String = "Name of the current wiki's topic navigated"
            toReturn.Add(New GroupParamsRewrite("WikiTopic", desc, RewriteType.SubPath, UrlParam.FromSyntax("topic")))
            Return toReturn
        End Function

        Public Function RewriteParams(ByVal groupName As String, ByVal objRewriteType As RewriteType, _
                                       ByVal params As Dictionary(Of UrlParam, String), ByVal behaviour As FriendlierUrlStrategy) As GroupRewriteResult _
            Implements IUrlRewriterProvider.RewriteParams
            Dim toReturn As New GroupRewriteResult()

            If params.Count > 0 Then
                Select Case groupName.ToLowerInvariant
                    Case "wikitopic"
                        'toReturn.RewriteValue = behaviour.StringEscaper.EscapeString(params(UrlParam.FromSyntax("topic")))
                        toReturn.RewriteValue = params(UrlParam.FromSyntax("topic"))
                        toReturn.ConsumedParameters(UrlParam.FromSyntax("topic")) = True
                End Select
            End If
            Return toReturn
        End Function

        Public ReadOnly Property IsActive As Boolean Implements IIsActive.IsActive
            Get
                Return DotNetNuke.Framework.Reflection.CreateType("DotNetNuke.Modules.Wiki.Entities.TopicController", True) IsNot Nothing
            End Get
        End Property
    End Class
End Namespace


